#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int n, r;

void Dfs(int index, vector<int>& nums, vector<int>& now) {
	if (now.size() == r) {
		for (int i = 0; i < r; i++) {
			cout << setw(3) << now[i];
		}
		cout << "\n";
		return;
	}

	for (int i = index; i <= n; i++) {
		now.push_back(nums[i]);
		Dfs(i + 1, nums, now);
		now.pop_back();
	}


}


/**
 * https://www.luogu.com.cn/problem/P1157
 */
int main() {
	cin >> n >> r;

	vector<int> nums(n+1, 0);

	for (int i = 1; i <= n; i++) {
		nums[i] = i;
	}

	vector<int> now;

	Dfs(1, nums, now);

	return 0;
}